from django.http import JsonResponse

# status
OK = 200
BAD_REQUEST = 400
SERVER_ERROR = 500

# code
SUCCESS = 0
ERROR = 1


class Response:
    @staticmethod
    def success(data=None, message="success"):
        return JsonResponse(
            {"data": data, "code": SUCCESS, "message": message}, status=OK
        )

    @staticmethod
    def server_error(message="", data=None):
        return JsonResponse(
            {"data": data, "code": ERROR, "message": message}, status=SERVER_ERROR
        )

    @staticmethod
    def bad_request(message="bad request"):
        return JsonResponse(
            {
                "data": None,
                "code": ERROR,
                "message": message,
            },
            status=BAD_REQUEST,
        )
